package com.qs.controller;


import com.qs.model.entity.User;
import com.qs.model.vo.UserVo;
import com.qs.response.Response;
import com.qs.service.IUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-03-25
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class UserController {

    private final IUserService userService;

    /**
     * 根据用户id查询用户信息
     * @param userId
     * @return
     */
    @GetMapping("/query/{userId}")
    public Response queryData(@PathVariable("userId") Integer userId){
        User user = userService.getById(userId);
        return Response.success(user);
    }

    /**
     * 修改用户信息
     * @param userVo
     * @return
     */
    @PostMapping("/update")
    public Response updateUserInfo(@RequestBody UserVo userVo){
        userService.updateUserInfo(userVo);
        return Response.success();
    }
}
